Skip to content

Raise 4K storage#890

Draft
gmarull wants to merge 2 commits intocoredevices:mainfrom
teslabs:raise-4k-storage
Draft

Raise 4K storage#890
gmarull wants to merge 2 commits intocoredevices:mainfrom
teslabs:raise-4k-storage

Conversation

@gmarull
Copy link
Member

@gmarull gmarull commented Feb 23, 2026

Fixes #416

gmarull and others added 2 commits February 23, 2026 17:43
Raise the per-app persistent storage limit from 6 KiB to 1 MiB. Modern
Pebble watches have 32 MB of flash storage, so a 1 MiB per-app limit is
reasonable. Update the API documentation accordingly.

Fixes coredevices#416

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
Commit f88a27b raised PERSIST_STORAGE_MAX_SPACE from 6 KiB to 1 MiB,
but settings_file_open pre-allocates the PFS file at ~120% of
max_used_space. This means every persist file now claims ~1.2 MiB of
flash regardless of actual usage, while most apps use only a few hundred
bytes.

Decouple the enforcement cap from the physical allocation by adding an
alloc_used_space field to SettingsFile that tracks the physical
allocation budget separately from max_used_space. A new
settings_file_open_growable() API sets alloc_used_space to a small
initial value. When a write needs more physical space but fits within
the enforcement cap, the file is automatically grown via rewrite with
doubling allocation (e.g. 4K -> 8K -> 16K -> ... -> 1M).

The persist service now uses settings_file_open_growable() with a 4 KiB
initial allocation (~5 KiB physical), close to the old 6 KiB limit.
Existing callers of settings_file_open() are unchanged (alloc_used_space
equals max_used_space, preserving the old pre-allocation behavior).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
@gmarull gmarull mentioned this pull request Feb 23, 2026
1 task
@matejdro
Copy link

Is the max value exposed somewhere in the stg?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Raise 4K storage limit

2 participants